import Login from "../pages/Login";
import Article from "../pages/Article";
import { createBrowserRouter } from "react-router-dom";
import Layout from "../pages/Layout";
import Board from "../pages/Board";
import About from "../pages/About";
import NotFound from "../pages/NotFound";
import { createHashRouter } from "react-router-dom";

// 配置路由规则
const router = createBrowserRouter([
  {
    path: "/",
    element: <Layout></Layout>,
    children: [
      // path与element的两种写法
      {
        // path: "board",
        // 设置为默认二级路由，在访问一级路由时自动展示该二级路由
        index: true,
        element: <Board></Board>,
      },
      {
        path: "/about",
        element: <About />,
      },
    ],
  },
  {
    path: "/login/:id/:name",
    element: <Login />,
  },
  {
    // 在路径中添加展占位符获取params参数
    path: "/article",
    element: <Article />,
  },
  {
    // * 通配符，上面path全部不匹配时，匹配此路由
    path: "*",
    element: <NotFound />,
  },
]);

export default router;
